package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.regulatorDevice_monitor.RegulatorDevice_MonitorGetModel;
import com.hzhr.iot.device.model.regulatorDevice_monitor_collectData.RegulatorDevice_Monitor_CollectDataGetModel;
import com.hzhr.iot.device.service.RegulatorDevice_MonitorService;
import com.hzhr.iot.device.service.RegulatorDevice_Monitor_CollectDataService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "RegulatorDevice_Monitor_CollectData", description = "调压设备下的监控设备的采集数据")
@RestController
@RequestMapping(value = "")
public class RegulatorDevice_Monitor_CollectDataController extends BaseController {
    @Autowired
    RegulatorDevice_Monitor_CollectDataService regulatorDevice_monitor_collectDataService;

    //region /regulator-devices/{regulatorDeviceId}/monitors GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询调压设备下的监控设备", notes="查询调压设备下的监控设备  \n步骤 :  \n1. 查询调压设备 :  \n查询COLLECT_DEVICE对象regulator_1，  \n查询规则如下：  \n          (1) COLLECT_DEVICE.ID == 路径参数regulatorDeviceId;  \n          (2) COLLECT_DEVICE.IS_VALID == '1'；  \n如果regulator_1不存在，抛出异常201；  \n2. 查询调压设备的下的监控设备 :  \n查询IOT_DEVICE对象monitor_1,  \n查询规则如下：  \n          (1) IOT_DEVICE.COLLECT_DEVICE_ID == regulator_1.ID;  \n          (2) IOT_DEVICE.ID = 路径参数monitorId;  \n          (3) IOT_DEVICE.IS_VALID == '1';  \n3. 查询监控设备的采集数据(根据采集时间降序排列)  \n查询REGULATOR_COLLECT_DATA对象集合collectDatas_1及总数，  \n查询规则如下：  \n          (1) 条件参数的筛选条件;  \n          (2) COLLECT_DATA.IOT_DEVICE_ID = monitor_1.ID;  \n          (3) COLLECT_DATA.IS_VALID = '1';  \n3. 返回信息  \n根据条件参数、collectDatas_1及总数生成RegulatorDevice_Monitor_CollectDataGetModel对象result并返回，  \nRegulatorDevice_Monitor_CollectDataModel与REGULATOR_COLLECT_DATA的对应关系如下：  \n          (1) RegulatorDevice_Monitor_CollectDataModel.inPressure => REGULATOR_COLLECT_DATA.IN_PRESSURE;  \n          (2) RegulatorDevice_Monitor_CollectDataModel.envTemperature => REGULATOR_COLLECT_DATA.ENV_TEMPERATURE;  \n          (3) RegulatorDevice_Monitor_CollectDataModel.outPressure1 => REGULATOR_COLLECT_DATA.OUT_PRESSURE1;  \n          (4) RegulatorDevice_Monitor_CollectDataModel.outPressure2 => REGULATOR_COLLECT_DATA.OUT_PRESSURE2;  \n          (5) RegulatorDevice_Monitor_CollectDataModel.outPressure3 => REGULATOR_COLLECT_DATA.OUT_PRESSURE3;  \n          (6) RegulatorDevice_Monitor_CollectDataModel.outPressure4 => REGULATOR_COLLECT_DATA.OUT_PRESSURE4;  \n          (7) RegulatorDevice_Monitor_CollectDataModel.outTemperature1 => REGULATOR_COLLECT_DATA.OUT_TEMPERATURE1;  \n          (8) RegulatorDevice_Monitor_CollectDataModel.outTemperature2 => REGULATOR_COLLECT_DATA.OUT_TEMPERATURE2;  \n          (9) RegulatorDevice_Monitor_CollectDataModel.outTemperature3 => REGULATOR_COLLECT_DATA.OUT_TEMPERATURE3;  \n          (10) RegulatorDevice_Monitor_CollectDataModel.outTemperature4 => REGULATOR_COLLECT_DATA.OUT_TEMPERATURE4;  \n          (11) RegulatorDevice_Monitor_CollectDataModel.outStaTotalFlow1 => REGULATOR_COLLECT_DATA.OUT_STA_TOTAL_FLOW1;  \n          (12) RegulatorDevice_Monitor_CollectDataModel.outStaTotalFlow2 => REGULATOR_COLLECT_DATA.OUT_STA_TOTAL_FLOW2;  \n          (13) RegulatorDevice_Monitor_CollectDataModel.outStaTotalFlow3 => REGULATOR_COLLECT_DATA.OUT_STA_TOTAL_FLOW3;  \n          (14) RegulatorDevice_Monitor_CollectDataModel.outStaTotalFlow4 => REGULATOR_COLLECT_DATA.OUT_STA_TOTAL_FLOW4;  \n          (15) RegulatorDevice_Monitor_CollectDataModel.outStaFlowRate1 => REGULATOR_COLLECT_DATA.OUT_STA_FLOW_RATE1;  \n          (16) RegulatorDevice_Monitor_CollectDataModel.outStaFlowRate2 => REGULATOR_COLLECT_DATA.OUT_STA_FLOW_RATE2;  \n          (17) RegulatorDevice_Monitor_CollectDataModel.outStaFlowRate3 => REGULATOR_COLLECT_DATA.OUT_STA_FLOW_RATE3;  \n          (18) RegulatorDevice_Monitor_CollectDataModel.outStaFlowRate4 => REGULATOR_COLLECT_DATA.OUT_STA_FLOW_RATE4;  \n          (19) RegulatorDevice_Monitor_CollectDataModel.collectTime => REGULATOR_COLLECT_DATA.COLLECT_TIME;  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "monitorId", value = "监控设备编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_collectTime", value = "筛选条件 : where RegulatorDevice_Monitor_CollectDataModel.collectTime >= #{greaterthanorequal_collectTime}", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_collectTime", value = "筛选条件 : where RegulatorDevice_Monitor_CollectDataModel.collectTime < #{lessthan_collectTime}", required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_collectTime", value = "筛选条件 : where REGULATOR_COLLECT_DATA.COLLECT_TIME >= #{_greaterthanorequal_collectTime}", required = false, dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_collectTime", value = "筛选条件 : where REGULATOR_COLLECT_DATA.COLLECT_TIME < #{_lessthan_collectTime}", required = false, dataType = "long", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/monitors/{monitorId}/collect-datas", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_Monitor_CollectDataGetModel> get(@PathVariable("regulatorDeviceId")Integer regulatorDeviceId,@PathVariable("monitorId")Integer monitorId, @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDevice_Monitor_CollectDataGetModel responseBody = regulatorDevice_monitor_collectDataService.get(initHeader(), regulatorDeviceId,monitorId,query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion

}



































































































































































